package com.shuigu.controller;

import com.shuigu.response.ShuiGuResult;
import com.shuigu.pojo.dto.RoleMenuDto;
import com.shuigu.pojo.dto.RoleMenuParamDto;
import com.shuigu.service.ISysUserService;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/roleMenu")
public class RoleMenuController {

    private final ISysUserService userService;

    public RoleMenuController(ISysUserService userService) {
        this.userService = userService;
    }

    /**
     * 获取角色权限信息列表
     */
    @GetMapping("/list")
    public ShuiGuResult getList(RoleMenuParamDto roleMenuParamDto){
        return ShuiGuResult.success(userService.getRoleMenuList(roleMenuParamDto));
    }

    /**
     * 取消权限
     */
    @DeleteMapping("/delete")
    public ShuiGuResult deleteRoleMenu(Long[] ids){
        return ShuiGuResult.success(userService.deleteRoleMenu(ids));
    }

    /**
     * 为角色分配权限
     */
    @PostMapping("/add")
    public ShuiGuResult addRoleMenu(@RequestBody RoleMenuDto roleMenuDto){
        return ShuiGuResult.success(userService.insertRoleMenu(roleMenuDto));
    }

    /**
     * 查询所有权限
     */
    @GetMapping("/allMenu")
    public ShuiGuResult findAllMenu(){
        return ShuiGuResult.success(userService.findAllMenu());
    }
}
